<template>
  <div>
    <Header></Header> <!-- 子页面公共头部 -->
    <div class="ej_box">
      <div class="ej_center">
        <Crumbs :lmtitle="lmtitle"></Crumbs> <!-- 面包屑导航 -->
        <div class="clear"></div>
        <div class="row">

          <!-- <div class="col-md-3">
            <SeniorSearch @search="search"></SeniorSearch>
          </div> -->
          <div class="col-md-12">
            <div class="ej_content_box">
					<div class="ej_content">
						<div class="ej_content_nav">
							<div class="ej_content_nav_pc">
								<h2 class="ej_content_nav_pc_h2dt">
                                    <li class="activexz">搜索结果</li>
                  <!--  -->
									<!-- <li v-for="item in dhData"  @click="link(item.id)" :class="formdata.columnId == item.id?'activexz':''" >{{item.name}}</li> -->
								</h2>

								<div class="clearfix"></div>
							</div>
						</div>

						<div class="ej_content_editor">
							<div class="zcfg_con2">
								<div class="ej_content_title">
									<h2 class="ej_content_title_h2">{{formdata.title}}</h2>
								</div>
								<div class="ej_content_editor">
									<div class="txl_top" v-if="ishow">
                    <div class="txl_topcon">
                      <div class="txl_top_fl">发布者：{{formdata.author}}</div>
                      <div class="txl_top_fr">发布时间：
                        {{formdata.createTime | formatDate}}   阅读：<span>{{formdata.thumbs}}</span>次</div>
                    </div>
									</div>

									<div class="txl_nr">
							    <div class="ej_content_editor2" id="wrapper">
							    	<div id="controls">
                      <span class="medium selected" @click="setttingfont('14')">字体-</span>
                      <span class="medium" @click="setttingfont('17')">字体+</span>
									</div>
									<div v-html="formdata.content" :style="{fontSize:fontsize +'px'}"></div>
                  <ul v-if='formdata.fileUrl' class="txllist">
                    <li v-for="item in formdata.fileUrllist" @click="down(item.url)">
                      <i class="iconfont icon-Microsoft-Excel"></i> {{item.name}}
                    </li>
                  </ul>
								</div>
									</div>
								</div>

							</div>


						</div>
					</div>
				</div>
          </div>

          <div class="clearfix"></div>
        </div>


      </div>
    </div>
    <Foot></Foot> <!-- 网站公共底部 -->
  </div>
</template>
<script>
import Foot from "@/components/foot.vue";
import Crumbs from "@/components/crumbs.vue";
import SeniorSearch from "@/components/seniorsearch.vue";
import Cookies from 'js-cookie'
import { contentApiqueryOne } from "@/api/webviews";
import Header from "@/components/header.vue";
export default {
  name: "searchcontent",
  components: {
    Header,
    Crumbs,
    SeniorSearch,
    Foot
  },
  filters:{
    formatDate(data){
      if(data){
        return  data.split(' ')[0]
      }
    },
  },
  data() {
    return {
      dhData:[],
      ParentId:'',
      formdata:{},
      fontsize:'15',
      lmtitle:'搜索结果',
      ishow:true
    };
  },
  created() {
    this.dhData = JSON.parse(Cookies.get('navdata'))[this.$route.query.navId]
    // this.getdata(this.$route.query.id)
    if(this.$route.query.id == 'C0A8B1507E0441F28FA9448DF52AC6DC'||this.$route.query.id == '2293BE31C5B4449FA5487BA2228BA6ED'){
      this.ishow = false
    }
  },
  watch: {
	    //监听路由地址的改变
	    $route:{
	        immediate:true,
	        handler(){
	            if(this.$route.query.id){//需要监听的参数
                this.getdata(this.$route.query.id)
                // this.lmtitle = JSON.parse(Cookies.get('navdata'))[this.$route.query.navId][0].name
                // this.dhData = JSON.parse(Cookies.get('navdata'))[this.$route.query.navId]
	            }
	        }
	    }
	},
  methods: {
    down(item){
      window.open(item,"_blank")
    },
    search(val){
      /*this.$router.push({
          name: 'searchresult',
          query:{formdata: JSON.stringify(val)}
      })*/
      let routeData = this.$router.resolve({
        name: 'searchresult',
        query:{formdata: JSON.stringify(val)}
      })
      window.open(routeData.href, '_blank')
    },
    setttingfont(fontsize){
      this.fontsize = fontsize
    },
    getdata(id) {
      contentApiqueryOne({ id: id })
        .then((res) => {
          if (res.code == 0) {
            this.formdata = res.data;
            console.log("🚀 ~ file: searchcontent.vue:138 ~ .then ~ res.data:", res.data)
            this.formdata.fileUrllist = []
            if(res.data.fileUrl){
            let arrya=[]
            arrya = this.formdata.fileUrl = res.data.fileUrl.split(",")
             arrya.map(item=>{
              this.formdata.fileUrllist.push(
                {
                  name:item.replace("/",""),
                  url:'/show'+item
                }
              )
            })
          }
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    link(id){
      /*this.$router.push({
          name: 'articlelistpage',
          query:{navId:this.$route.query.navId,id:id}
      })*/

      let routeData = this.$router.resolve({
        name: 'articlelistpage',
        query:{navId:this.$route.query.navId,id:id}
      })
      window.open(routeData.href, '_blank')
    },
  },
};
</script>
<style>
  @import "../assets/css/font/iconfont.css";
  @import "../assets/css/index.css";
  @import "../assets/css/style.css";
  </style>
